package com.ruangong.GitClient.app;

import android.os.Bundle;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.ruangong.GitClient.R;

public class HunhepanMenu extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hunhepan_menu);

        BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);

        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                Fragment selectedFragment = null;

                switch (item.getItemId()) {
                    case R.id.navigation_function1:
                        selectedFragment = new MovieSearch();
                        break;
                    case R.id.navigation_function2:
                        selectedFragment = new NewResource();
                        break;
                    case R.id.navigation_function3:
                        selectedFragment = new TabList();
                        break;
                }

                getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, selectedFragment).commit();
                return true;
            }
        });

        // 设置默认片段
        if (savedInstanceState == null) {
            bottomNavigationView.setSelectedItemId(R.id.navigation_function3);
        }
    }
}


